home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / netutils / nbdriv.arj / NETWORK.DOC < prev    next >
Text File  |  1993-10-29  |  3KB  |  107 lines

  1. NETWORK.SYS is a small DOS device driver that allows a program to send
  2. datagrams over a Netbios network (Lantastic) as if the network were a
  3. character device.
  4.  
  5. The small C example illustrates how the driver is called from a
  6. C program. If Netbios is not present or for some other reason is
  7. not working, the fopen() will fail. If there is no network message
  8. available, fread() returns a 0 length result.
  9.  
  10. Following the C example is a small Quick Basic program which performs
  11. the same function.
  12.  
  13. Installing NETWORK.SYS uses the following syntax:
  14.  
  15.     DEVICE=<pathname>NETWORK.SYS <NODE_NAME>
  16.  
  17.     where NODE_NAME can be as follows:
  18.  
  19.     DEVICE=<pathname>NETWORK.SYS HOST or
  20.     DEVICE=<pathname>NETWORK.SYS DEV1
  21.  
  22. The name of the network node is the 4 characters following the device
  23. statement. There should be only one space between SYS and the node name.
  24.  
  25. The format of the message sent is <NODE_NAME><Message>
  26.  
  27. The device driver uses the Netbios SEND_DATAGRAM function so any message
  28. sent looks like a new message for the sender as well so the driver
  29. discards the message if the node name matches the sender.
  30.  
  31. #include <stdio.h>
  32. void main(void);
  33. void main()
  34.     {
  35.     FILE  *device;
  36.     char  InBuff[128];
  37.     char  Message[128];
  38.     short BuffIndex;
  39.  
  40.     device = fopen("NETBIOS1","r+");
  41.     if (device == NULL)
  42.     {
  43.     printf("Error opening device\n");
  44.     }
  45.     else
  46.     {
  47.     //
  48.     // read to see if there is a message available
  49.     //
  50.     BuffIndex = fread(InBuff,sizeof(char),128,device);
  51.     InBuff[BuffIndex] = '\0';
  52.     printf("Chars Read = %d [%s]\n",BuffIndex,InBuff);
  53.     //
  54.     // ask for message to send
  55.     //
  56.     printf("\nEnter Message To Send ..... ");
  57.     gets(Message);
  58.     if (strlen(Message) != 0)
  59.         {
  60.         fprintf(device,"%s\r",Message);
  61.         }
  62.     fclose(device);
  63.     }
  64.     }
  65.  
  66. rem
  67. rem    test for a network message
  68. rem
  69.      OPEN "NETBIOS1" FOR INPUT AS #1
  70.      IF EOF(1) GOTO 1002
  71.      INPUT #1, a$
  72.      PRINT a$
  73.      GOTO 1003
  74. 1002 PRINT "No Network Message"
  75. 1003 CLOSE
  76. rem
  77. rem send a message
  78. rem
  79.      OPEN "NETBIOS1" FOR OUTPUT AS #1
  80.      PRINT "Enter Message to Send...";
  81.      INPUT a$
  82.      IF LEN(a$) = 0 THEN GOTO 1004
  83.      PRINT #1, a$
  84. 1004 CLOSE
  85.  
  86. The ASM source code (NETWORK.ASM) is included in the zip file as well as
  87. the executable file (NETWORK.SYS).
  88.  
  89. The program is assembled using the following commands:
  90.  
  91. masm network;
  92. link network;
  93. exe2com network network.sys
  94. Note: exe2com can be found on CompuServe
  95.  
  96. A small diagnostic tool is also included - SHOWDDH, which is a modification
  97. of a similar program in "Writing Device Drivers in C" by Adams & Tondo.
  98. It will verify that NETWORK.SYS is loaded and show where it is in memory
  99. so that you can look at the buffers if desired. Included are SHOWDDH.C
  100. and SHOWDDH.EXE.
  101.  
  102. I would prefer not to provide nationwide tech support but I will try to
  103. answer EMAIL questions to:
  104. Steve Bean, MicroPlot Systems Co.
  105. CompuServe: 70575,406
  106. Internet: 70575.406@CompuServe.COM
  107.